package org.msfj.admin.api;

import org.msfj.admin.data.service.HolidayService;
import org.msfj.admin.feign.HolidayApi;
import org.msfj.admin.vo.HolidayVo;
import org.msfj.admin.data.service.HolidayService;
import org.msfj.admin.feign.HolidayApi;
import org.msfj.admin.vo.HolidayVo;
import org.msfj.admin.data.service.HolidayService;
import org.msfj.admin.feign.HolidayApi;
import org.msfj.admin.vo.HolidayVo;
import org.msfj.common.model.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@RestController
public class HolidayApiImpl implements HolidayApi {

    @Autowired
    HolidayService holidayService;

    @Override
    public CommonResult<Date> workDayAfter(@RequestParam("startTime") Date startTime, @RequestParam("workDay") Integer workDay) {
        return CommonResult.ok(holidayService.workDayAfter(startTime, workDay));
    }

    @Override
    public CommonResult<Date> workHourAfter(@RequestParam("startTime") Date startTime, @RequestParam("limitHour") Integer limitHour) {
        return CommonResult.ok(holidayService.workHourAfter(startTime, limitHour));
    }

    @Override
    public CommonResult<Boolean> isHoliday(@RequestParam("date") Date date) {
        return CommonResult.ok(holidayService.isHoliday(date));
    }

    @Override
    public CommonResult<List<HolidayVo>> getHolidaysByYear(String year) {
        HolidayVo holidayVo = new HolidayVo();
        holidayVo.setYear(year);
        List<HolidayVo> holidayVos = holidayService.getAllHoliday(holidayVo);
        return CommonResult.ok(holidayVos);
    }
}
